home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / include / stdarg.h < prev    next >
C/C++ Source or Header  |  1990-07-23  |  1KB  |  30 lines

  1. /* The <stdarg.h> header is ANSI's way to handle variable numbers of params.
  2.  * Some programming languages require a function that is declared with n
  3.  * parameters to be called with n parameters.  C does not.  A function may
  4.  * called with more parameters than it is declared with.  The well-known
  5.  * printf function, for example, may have arbitrarily many parameters.
  6.  * The question arises how one can access all the parameters in a portable
  7.  * way.  The C standard defines three macros that programs can use to
  8.  * advance through the parameter list.  The definition of these macros for
  9.  * MINIX are given in this file.  The three macros are:
  10.  *
  11.  *    va_start(ap, parmN)    prepare to access parameters
  12.  *    va_arg(ap, type)    get next parameter value and type
  13.  *    va_end(ap)        access is finished
  14.  */
  15.  
  16. #ifndef _STDARG_H
  17. #define _STDARG_H
  18.  
  19. typedef    char *va_list;
  20.  
  21. #define __vasz(x)        ((sizeof(x)+sizeof(int)-1) & ~(sizeof(int) -1))
  22.  
  23. #define va_start(ap, parmN)    ((ap) = (va_list)&parmN + __vasz(parmN))
  24. #define va_arg(ap, type)      \
  25.   (*((type *)((va_list)((ap) = (void *)((va_list)(ap) + __vasz(type))) \
  26.                             - __vasz(type))))
  27. #define va_end(ap)
  28.  
  29. #endif /* _STDARG_H */
  30.